package com.student.liu.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.student.liu.service.IGoodsService;
import com.student.liu.service.IGoodsSpecService;
import lombok.Data;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.Map;
import java.util.Random;

@RestController
@RequestMapping("spec")
public class GoodsSpecController extends BaseController{
    @Resource
    IGoodsSpecService goodsSpecService;

    @PostMapping("page")
    public Object page(@Valid @RequestBody GoodsSpecController.GoodsSpecPageBody goodsSpecPageBody, BindingResult result) throws InterruptedException {
        IPage<Map<String, Object>> goodsMaps = goodsSpecService.goodsSpec(1, 15,
                goodsSpecPageBody.getGoodsId());

        return success("", goodsMaps);
    }

    @Data
    static class GoodsSpecPageBody {
        @NotNull(message = "请传递类型，默认请传递0")
        private Integer goodsId;
    }

}
